﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using LPV_POS.Baocao;
using LPV_POS.Module;
using CrystalDecisions.CrystalReports.Engine;
using LPV_POS.Baocao.Ellic;
using System.Resources;
using System.Globalization;

namespace LPV_POS.mh_baocao
{
    public partial class mh_dmbaocao : DevExpress.XtraEditors.XtraForm
    {
        CultureInfo culture;
        #region "Muti language"

        private void SetLanguage_banhang(string cultureName)
        {
            try
            {
                culture = CultureInfo.CreateSpecificCulture(cultureName);
                ResourceManager rm = new ResourceManager("LPV_POS.Muti_language.MyResource", typeof(mh_dmbaocao).Assembly);
                lbel_baocaotatca.Text = rm.GetString("baocaotatca", culture);
                lbel_baocaodoanhthu.Text = rm.GetString("baocaodoanhthu", culture);
                lbel_baocaohienhanh.Text = rm.GetString("baocaohienhanh", culture);
                lbel_thoat.Text = rm.GetString("thoat", culture);
                 
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Note");
            }

        }

        #endregion
        public mh_dmbaocao(DataSet _dsBaocao)
        {
            InitializeComponent();
            dsBaocao = _dsBaocao;
        }

        public int str_loaibaocao = 0;
        private void lickdown(object sender, MouseEventArgs e)
        {
            ((Label)sender).BackColor = Color.FromArgb(192, 249, 251);
            ((Label)sender).BorderStyle = BorderStyle.Fixed3D;
        }

        private void lickup(object sender, MouseEventArgs e)
        {
            ((Label)sender).BackColor = Color.FromArgb(144, 196, 255);
            ((Label)sender).BorderStyle = BorderStyle.FixedSingle;
        }
        DataSet dsBaocao;

        private void lbel_baocaotatca_MouseDown(object sender, MouseEventArgs e)
        {
            lickdown(sender, e);
        }

        private void lbel_baocaotatca_MouseUp(object sender, MouseEventArgs e)
        {
            lickup(sender, e);     
        }

        private void lbel_baocaotatca_Click(object sender, EventArgs e)
        {

            str_loaibaocao = 1;
            this.DialogResult = DialogResult.OK;
            this.Close();

        }

        private void lbel_baocaodoanhthu_Click(object sender, EventArgs e)
        {
            str_loaibaocao = 2;
            this.DialogResult = DialogResult.OK;
            this.Close();
        }

        private void lbel_baocaohienhanh_Click(object sender, EventArgs e)
        {

            str_loaibaocao = 3;
            this.DialogResult = DialogResult.OK;
            this.Close();
            return;

            if (dsBaocao == null)
            {
                Mod_messagebox mess = new Mod_messagebox();
                mess.messagebox_pos("Thông báo", "Chưa có dữ liệu", loaithongbao.yesno.GetHashCode());
                return;
            }

            // chon dia chi luu file excel
            mh_save frm_save = new mh_save();
            frm_save.ShowDialog();
            if (frm_save.path_excel == "")
                return;
            ReportDocument CrReport=null;
            Mod_baocao bc=null;
            switch (dsBaocao.Tables[0].Rows[0]["LOAI"] + "" )
            {

                case "NHOMCHU":
                        CrReport = new bc_nhomchu();
                         bc = new Mod_baocao();
                        bc.f_header_report(CrReport);
                        Mod_baocaonhomchu baocaonhomchu = new Mod_baocaonhomchu();
                        baocaonhomchu.rpt_baocaonhomchu(dsBaocao, CrReport,frm_save.path_excel);
                        break;
                        
                case "NHOMHANG":
                        CrReport = new bc_nhomhang();
                        bc = new Mod_baocao();
                        bc.f_header_report(CrReport);
                        Mod_baocaonhomhang baocaonhomhang = new Mod_baocaonhomhang();
                        baocaonhomhang.rpt_baocaonhomhang(dsBaocao, CrReport, frm_save.path_excel);
                        break;

                case "HANGHOA":
                        CrReport = new bc_hanghoa();
                        bc = new Mod_baocao();
                        bc.f_header_report(CrReport);
                        Mod_baocaohanghoa baocaohanghoa = new Mod_baocaohanghoa();
                        baocaohanghoa.rpt_baocaohanghoa(dsBaocao, CrReport,  frm_save.path_excel);
                        break;

                case "NHANVIEN":
                        CrReport = new bc_nhanvien();
                        bc = new Mod_baocao();
                        bc.f_header_report(CrReport);
                        Mod_baocaonhanvien baocaonhanvien = new Mod_baocaonhanvien();
                        baocaonhanvien.rpt_baocaonhanvien(dsBaocao, CrReport, frm_save.path_excel);
                        break;
                case "KHACHHANG":
                        CrReport = new bc_khachhang();
                        bc = new Mod_baocao();
                        bc.f_header_report(CrReport);
                        Mod_baocaokhachhang baocaokhachang = new Mod_baocaokhachhang();
                        baocaokhachang.rpt_baocaokhachhang(dsBaocao, CrReport, frm_save.path_excel);
                        break;
                case "KHOHANG":
                        CrReport = new bc_khohang();
                        bc = new Mod_baocao();
                        bc.f_header_report(CrReport);
                        Mod_baocaokhohang baocaokhohang = new Mod_baocaokhohang();
                        baocaokhohang.rpt_baocaokhohang(dsBaocao, CrReport, frm_save.path_excel);
                        break;
                case "KHUVUC":
                        CrReport = new bc_khuvuc();
                        bc = new Mod_baocao();
                        bc.f_header_report(CrReport);
                        Mod_baocaokhuvuc baocaokhuvuc = new Mod_baocaokhuvuc();
                        baocaokhuvuc.rpt_baocaokhuvuc(dsBaocao, CrReport, frm_save.path_excel);
                        break;
                case "KHUVUC_CT":
                case "BAN":
                        CrReport = new bc_ban();
                        bc = new Mod_baocao();
                        bc.f_header_report(CrReport);
                        Mod_baocaoban baocaoban = new Mod_baocaoban();
                        baocaoban.rpt_baocaoban(dsBaocao, CrReport, frm_save.path_excel, dsBaocao.Tables[0].Rows[0]["LOAI"] + "");
                        break;
                        
                
            }
            dsBaocao = null;
            this.Close();
          
         
        }

        private void mh_dmbaocao_Load(object sender, EventArgs e)
        {
            cpublic ocpublic = new cpublic();
            string str_lang = ocpublic.Registry_Get("mh_main_lang");
            if (str_lang == "")
                str_lang = "vi-VN";
            SetLanguage_banhang(str_lang);
        }

        private void lbel_thoat_Click(object sender, EventArgs e)
        {
            //Mod_messagebox mess = new Mod_messagebox();
            //mess.messagebox_pos("Thông báo", "Bạn muốn thoát?", loaithongbao.yesno.GetHashCode());
            //if (Variable.thongbao == true)
            //{

                this.Close();
            //}
        }

       
    }
}